import axios from '@/utils/request'

// 内容管理功能
export function getArticles (params = {}) {
  return axios({
    method: 'get',
    url: '/mp/v1_0/articles',
    params
  })
}

// 获取频道
export function getChannels () {
  return axios({
    method: 'get',
    url: '/mp/v1_0/channels'
  })
}

// 删除内容管理的文章
export function delArticel (id) {
  return axios({
    method: 'delete',
    url: `/mp/v1_0/articles/${id}`
  })
}

// 发表文章
export function addArticel (data) {
  return axios({
    method: 'POST',
    url: '/mp/v1_0/articles',
    data
  })
}

// 修改评论的状态
export function changeCommentStatus (id, allow_comment) {
  return axios({
    method: 'put',
    url: '/mp/v1_0/comments/status',
    params: {
      article_id: id
    },
    data: {
      allow_comment
    }
  })
}

// 获取指定的文章的信息
export function getArticleSure (id) {
  return axios({
    method: 'GET',
    url: '/mp/v1_0/articles/' + id
  })
}

// 修改文章后发的请求
export function uppdateArticle (id, data) {
  return axios({
    method: 'PUT',
    url: '/mp/v1_0/articles/' + id,
    data
  })
}
